<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
   
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['cases:judicial:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="caseDetailsList" @selection-change="handleSelectionChange"
      border
      stripe
      style="width: 100%"
      :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
      >
      <el-table-column label="案件名称" align="center" prop="casesName" :show-overflow-tooltip="true" >
     </el-table-column>
      <el-table-column label="案件类别" align="center" prop="casesCategory" >  
      </el-table-column>
      <el-table-column label="承办检察官" align="center" prop="contractorName"  :formatter="(row) => '***'"/>
      <el-table-column label="嫌疑人姓名" align="center" prop="suspectName" />
      <el-table-column label="承办部门" align="center" prop="handleDept" />
      <el-table-column label="统一业务" align="center" prop="uniteBusy" />
      <el-table-column label="案件年份" align="center" prop="caseYear" />
      <el-table-column label="嫌疑人编号" align="center" prop="suspectNum" />
      <el-table-column label="磋商日期" align="center" prop="adviceDate" />
      <el-table-column label="磋商结果" align="center" prop="adviceResult" />
      <el-table-column label="磋商终结案件日期" align="center" prop="adviceEndDate" />
      <el-table-column label="磋商终结案件情形" align="center" prop="adviceEndResult" :show-overflow-tooltip="true"/>
  
      <el-table-column label="部门受案号" align="center" prop="deptAcceptMark" />
      <el-table-column label="统一受案号" align="center" prop="uniteMark" />
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listCaseDetails, getCaseDetails} from "@/api/cases/judicial"

export default {
  name: "Judicial",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 案件详情信息表格数据
      caseDetailsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        casesName: null,
        casesCategory: null,
        contractorName: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {

    shouldShowTooltip(content, maxLength) {
      if (!content) return true;
      // 计算实际显示宽度（考虑中英文字符差异）
      const width = Array.from(content).reduce((acc, char) => {
        return acc + (char.charCodeAt(0) > 255 ? 2 : 1);
      }, 0);
      return width <= maxLength;
    },
    formatTooltipContent(content) {
      // 处理可能存在的换行符和特殊字符
      return content ? content.replace(/\n/g, ' ') : '';
    },
    /** 查询案件详情信息列表 */
    getList() {
      this.loading = true
      listCaseDetails(this.queryParams).then(response => {
        this.caseDetailsList = response.rows
        this.total = response.total
        this.loading = false
      })
    },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        casesName: null,
        casesCategory: null
     
      }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
  
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/caseDetails/exportJud', {
        ...this.queryParams
      }, `caseDetails_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
<style scoped>
/* 表格行高和文本溢出控制 */
.el-table {
  font-size: 13px;
}
.el-table ::v-deep .el-table__row {
  height: 28px;
}
.el-table ::v-deep .el-table__cell {
  padding: 4px 0;
}
.cell-content {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

</style>

